package cn.zero.wechat.req;

import java.lang.reflect.Field;

public class WechatMpMessage {
	private String ToUserName;
	private String FromUserName;
	private Long CreateTime;
	// 消息类型（text/image/location/link/voice）
	private String MsgType;
	private Long MsgId;

	// text
	private String Content;

	// image
	private String PicUrl;

	// link
	private String Title;
	private String Description;
	private String Url;

	// location
	// 地理位置维度
	private String Location_X;
	// 地理位置经度
	private String Location_Y;
	// 地图缩放大小
	private String Scale;
	// 地理位置信息
	private String Label;

	// ShakearoundUserShake
	private String Uuid;
	private String Major;
	private String Minor;
	private double Distance;

	// video
	private String MediaId;
	private String ThumbMediaId;

	// voice
	private String Format;
	private String Recognition;

	// -- Event
	private String Event;

	// Location
	// 地理位置维度
	private String Latitude;
	// 地理位置经度
	private String Longitude;
	// 地理位置经度
	private String Precision;

	// Menu
	// Menu
	private String MenuId;
	private String EventKey;

	public String getToUserName() {
		return ToUserName;
	}

	public void setToUserName(String toUserName) {
		ToUserName = toUserName;
	}

	public String getFromUserName() {
		return FromUserName;
	}

	public void setFromUserName(String fromUserName) {
		FromUserName = fromUserName;
	}

	public Long getCreateTime() {
		return CreateTime;
	}

	public void setCreateTime(Long createTime) {
		CreateTime = createTime;
	}

	/**
	 * setField用到
	 * @param createTimeStr
	 */
	public void setCreateTime(String createTimeStr) {
		CreateTime = Long.parseLong(createTimeStr);
	}
	
	public String getMsgType() {
		return MsgType;
	}

	public void setMsgType(String msgType) {
		MsgType = msgType;
	}

	public Long getMsgId() {
		return MsgId;
	}

	public void setMsgId(Long msgId) {
		MsgId = msgId;
	}

	public String getContent() {
		return Content;
	}

	public void setContent(String content) {
		Content = content;
	}

	public String getPicUrl() {
		return PicUrl;
	}

	public void setPicUrl(String picUrl) {
		PicUrl = picUrl;
	}

	public String getTitle() {
		return Title;
	}

	public void setTitle(String title) {
		Title = title;
	}

	public String getDescription() {
		return Description;
	}

	public void setDescription(String description) {
		Description = description;
	}

	public String getUrl() {
		return Url;
	}

	public void setUrl(String url) {
		Url = url;
	}

	public String getLocation_X() {
		return Location_X;
	}

	public void setLocation_X(String location_X) {
		Location_X = location_X;
	}

	public String getLocation_Y() {
		return Location_Y;
	}

	public void setLocation_Y(String location_Y) {
		Location_Y = location_Y;
	}

	public String getScale() {
		return Scale;
	}

	public void setScale(String scale) {
		Scale = scale;
	}

	public String getLabel() {
		return Label;
	}

	public void setLabel(String label) {
		Label = label;
	}

	public String getUuid() {
		return Uuid;
	}

	public void setUuid(String uuid) {
		Uuid = uuid;
	}

	public String getMajor() {
		return Major;
	}

	public void setMajor(String major) {
		Major = major;
	}

	public String getMinor() {
		return Minor;
	}

	public void setMinor(String minor) {
		Minor = minor;
	}

	public double getDistance() {
		return Distance;
	}

	public void setDistance(double distance) {
		Distance = distance;
	}

	public String getMediaId() {
		return MediaId;
	}

	public void setMediaId(String mediaId) {
		MediaId = mediaId;
	}

	public String getThumbMediaId() {
		return ThumbMediaId;
	}

	public void setThumbMediaId(String thumbMediaId) {
		ThumbMediaId = thumbMediaId;
	}

	public String getFormat() {
		return Format;
	}

	public void setFormat(String format) {
		Format = format;
	}

	public String getRecognition() {
		return Recognition;
	}

	public void setRecognition(String recognition) {
		Recognition = recognition;
	}

	public String getEvent() {
		return Event;
	}

	public void setEvent(String event) {
		Event = event;
	}

	public String getLatitude() {
		return Latitude;
	}

	public void setLatitude(String latitude) {
		Latitude = latitude;
	}

	public String getLongitude() {
		return Longitude;
	}

	public void setLongitude(String longitude) {
		Longitude = longitude;
	}

	public String getPrecision() {
		return Precision;
	}

	public void setPrecision(String precision) {
		Precision = precision;
	}

	public String getMenuId() {
		return MenuId;
	}

	public void setMenuId(String menuId) {
		MenuId = menuId;
	}

	public String getEventKey() {
		return EventKey;
	}

	public void setEventKey(String eventKey) {
		EventKey = eventKey;
	}

	public void setField(String fieldName, Object value) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
		try {
			Field field = this.getClass().getDeclaredField(fieldName);
			if (field != null) {
				if(field.getGenericType().toString().equals("class java.lang.Long")) {
					field.set(this, Long.parseLong((String)value));
				} else if (field.getGenericType().toString().equals("class java.lang.Double") || field.getGenericType().toString().equals("double")) {
					field.set(this, Double.parseDouble((String)value));
				} else {
					field.set(this, value);
				}
			}
		} catch (NoSuchFieldException e) {
		} catch (Exception e) {

		}
	}

	@Override
	public String toString() {
		return "WechatMpMessage{" +
				"ToUserName='" + ToUserName + '\'' +
				", FromUserName='" + FromUserName + '\'' +
				", CreateTime=" + CreateTime +
				", MsgType='" + MsgType + '\'' +
				", MsgId=" + MsgId +
				", Content='" + Content + '\'' +
				", PicUrl='" + PicUrl + '\'' +
				", Title='" + Title + '\'' +
				", Description='" + Description + '\'' +
				", Url='" + Url + '\'' +
				", Location_X='" + Location_X + '\'' +
				", Location_Y='" + Location_Y + '\'' +
				", Scale='" + Scale + '\'' +
				", Label='" + Label + '\'' +
				", Uuid='" + Uuid + '\'' +
				", Major='" + Major + '\'' +
				", Minor='" + Minor + '\'' +
				", Distance=" + Distance +
				", MediaId='" + MediaId + '\'' +
				", ThumbMediaId='" + ThumbMediaId + '\'' +
				", Format='" + Format + '\'' +
				", Recognition='" + Recognition + '\'' +
				", Event='" + Event + '\'' +
				", Latitude='" + Latitude + '\'' +
				", Longitude='" + Longitude + '\'' +
				", Precision='" + Precision + '\'' +
				", EventKey='" + EventKey + '\'' +
				'}';
	}
}
